<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3><?php echo $lang['link_index_mb_class'];?></h3>
      <ul class="tab-base">
        <li><a href="index.php?act=wp_class&op=wp_class_list" ><span><?php echo $lang['nc_manage'];?></span></a></li>
        <li><a href="JavaScript:void(0);" class="current"><span><?php echo $lang['nc_new'];?></span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="link_form" enctype="multipart/form-data" method="post">
    <input type="hidden" name="form_submit" value="ok" />
    <table class="table tb-type2 nobdb">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="class_name"> <?php echo $lang['link_index_title'];?>:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="class_name" id="class_name" class="txt"></td>
          <td class="vatop tips">显示的标题</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="class_loc">显示位置:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
            <select id="class_loc" name="class_loc">
            	<option value="4">首页滚动广告</option>
            	<option value="0">首页分类</option>
            	<option value="1">今日快报</option>
            	<option value="2">商品促销</option>
            	<option value="3">推荐活动</option>
            </select>
          </td>
          <td class="vatop tips">广告显示的位置</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="class_type">跳转类型:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
            <select id="class_type" name="class_type">
            	<option value="0">商品</option>
            	<option value="1">商品分类</option>
            	<option value="2">活动页</option>
            	<option value="3">链接地址</option>
            </select>
          </td>
          <td class="vatop tips">广告跳转的类型，根据类型自动跳转到相应的页面</td>
        </tr>
        <tr>
          <td colspan="2" ><label for="class_url">链接地址或关联编号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
            <input type="text" name="class_url" id="class_url" value="<?php echo $output['link_array']['class_url'];?>" class="txt" >
          </td>
          <td class="vatop tips">根据跳转类型填写相应的编号或跳转地址</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="class_img"><?php echo $lang['link_index_pic_sign'];?>:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
          <span class="type-file-box">
            <input type="file" name="class_img" id="class_img" class="type-file-file" size="30" >
          </span>  
            </td>
          <td class="vatop tips"><?php echo $lang['link_add_sign'];?></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="class_order"><?php echo $lang['nc_sort'];?>:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="class_order" id="class_order" class="txt"></td>
          <td class="vatop tips"><?php echo $lang['link_add_sort_tip'];?></td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit'];?></span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表单
$(function(){$("#submitBtn").click(function(){
    if($("#link_form").valid()){
     $("#link_form").submit();
	}
	});
});
//
$(document).ready(function(){
	$('#link_form').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parentsUntil('tr').parent().prev().find('td:first'));
        },
        rules : {
            class_name : {
                required : true
            },
            class_order : {
                number   : true
            }
        },
        messages : {
            class_name : {
                required : '<?php echo $lang['link_add_title_null'];?>'
            },
            class_order  : {
                number   : '<?php echo $lang['link_add_sort_int'];?>'
            }
        }
    });
});
</script> 
<script type="text/javascript">
$(function(){
    var textButton="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />"
	$(textButton).insertBefore("#class_img");
	$("#class_img").change(function(){
	$("#textfield1").val($("#class_img").val());
});
});
</script>
